// 页面快捷键相关

// 快捷键配置
import {ElMessageBox} from "element-plus";
import {scrollHalf, scrollToBottom, scrollToTop} from "./ScrollUtils.ts";

export interface ShortKey {
    // 标题
    title: string
    // 快捷键
    keys: string[]
    // 触发事件
    action: () => void
    // 描述
    description?: string
}

// 使用弹窗显示快捷键
export const showShortKeys = (shortKeys: ShortKey[]) => {
    const message = shortKeys.map(k => `${k.keys.join(' + ')} : ${k.title}`).join('\n')
    ElMessageBox.alert(message, "热键", {customClass: 'alert-message', closeOnClickModal: true, closeOnPressEscape: true})
}

export const scrollShortKeys: ShortKey[] = [
    {title: '滚动到顶部', keys: ['shift', 'w'], action: scrollToTop},
    {title: '滚动到底部', keys: ['shift', 's'], action: scrollToBottom},
    {title: '向下滚动', keys: ['s'], action: () => scrollHalf()},
    {title: '向上滚动', keys: ['w'], action: () => scrollHalf(-1)},
]